package com.member;

import com.common.model.Member;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * 本 demo 仅表达最为粗浅的 jfinal 用法，更为有价值的实用的企业级用法
 * 详见 JFinal 俱乐部: http://jfinal.com/club
 * 
 * MemberValidator.
 */
public class MemberValidator extends Validator {
	
	protected void validate(Controller controller) {
		validateRequiredString("member.nickName", "nickNameMsg", "请输入Member昵称!");
	}
	
	protected void handleError(Controller controller) {
		controller.keepModel(Member.class);
		
		String actionKey = getActionKey();
		if (actionKey.equals("/member/save"))
			controller.render("add.html");
		else if (actionKey.equals("/member/update"))
			controller.render("edit.html");
	}
}
